<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <ul id="parent">
         <li>1</li>
         <li>2</li>
         <li>3</li>
    </ul>
    <script>
    // childnodes-->获取所有类型的节点
    // children-->只获取元素子节点
    var childs=document.getElementById("parent").children;
    var arr=array.prototype.slice.call(childs);
    arr.foreach(function(value,index){
        value.onclick=function(){
            arr.foreach((value,index)=>{
                value.style.color="#333"
            })
            this.style.color="red"
        }
    })
    </script>
</body>
</html>